<?php


include_once('lib/Template.class.php');
include_once('lib/Admin.class.php');
include_once('lib/User.class.php');
$t = new Template(translate('My Control Panel'));
$db = new DBEngine();
global $link;

$t->printHTMLHeader();
$t->printWelcome();
$fn = isset($_POST['fn']) ? $_POST['fn'] : (isset($_GET['fn']) ? $_GET['fn'] : '');	// Set function

$user = new User(Auth::getCurrentID());

if (!validate_function($user, $fn)) {
    CmnFns::do_error_box(translate('This is only accessable to the administrator') . '<br />'
        . '<a href="ctrlpnl.php">' . translate('Back to My Control Panel') . '</a>');
}


// Print HTML headers
echo "<?xml version=\"1.0\" encoding=\"$charset\"?" . ">\n";
$t->startMain();
?>

	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
		"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
	<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $languages[$lang][2]?>" lang="<?php echo $languages[$lang][2]?>">
	<head>
	<title>
	<?php echo 'Update Reservations'?>
	</title>
	<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset?>" />
	<script language="JavaScript" type="text/javascript" src="functions.js"></script>
	<style type="text/css">
	@import url(css.css);
	</style>
	</head>
	<body>
   <h3 align="center">Update Reservations</h3>

              

<?php
   echo 'Updating the reservations will invite and email all linked site coordinators to future reservations<br>';
   echo 'if their location has been added to the reservation and they are not a participant.<br>';
   echo 'This can take some time to complete.<br><br>';
   echo '<h6>Note:  This can generate a large amount of email.</h6><br><br>';
   echo '<p style="margin-top:10px;"><b>&raquo;</b> ' .  $link->getLink('updateres.php', 'Update all Reservations') . "</p>\n";
// Print HTML footer
$t->endMain();
?>
	<p align="center"><a href="http://phpscheduleit.sourceforge.net">phpScheduleIt v<?php echo $conf['app']['version']?></a></p>
	</body>
	</html>
<?php

/**
* Return if the user can access the update page
* @param User $user the user to evaluate
* @param string $function the requested function
* @return if the user can access the update page
*/
function validate_function(&$user, $function) {
	if (Auth::isAdmin() || $user->get_isadmin()) {
		return true;
	}

	if ( $function == 'editPerms' || $function == 'resetPass' ) {
		return $user->is_group_admin();
	}

	return false;
}
?>